/*
 * Player.cpp
 *
 *  Created on: 24 déc. 2010
 *      Author: remz
 */
#include <iostream>
#include <string>

#include "Player.h"
#include "../Option/Option.h"

#define PLAYER rpg::Player

using namespace std;

PLAYER::Player(string Name /*= string()*/, int Sexe /*= 0*/, int Class /* = 0*/, int Level /*= 0*/,	int Str/* = 0*/,
		       int Dext /*= 0*/, int Int /*= 0*/, int Hp /*= 0*/, int Mp/* = 0*/, int Weapon /*= 0*/, int Armor /*= 0*/, int Xp /*= 0*/)
	: m_Name(Name), m_Sexe(Sexe), m_Class(Class), m_Level(Level), m_Str(Str), m_Dext(Dext), m_Int(Int), m_Hp(Hp), m_Mp(Mp),
	  m_Weapon(Weapon), m_Armor(Armor), m_Xp(Xp)
{}

PLAYER::~Player(void)
{
	
}

string PLAYER::getName() const
{
	return m_Name;
} // getName()

void PLAYER::setName(string Name)
{
	m_Name = Name;
} // setName()

int PLAYER::getSexe() const
{
	return m_Sexe;
} // getSexe()

void PLAYER::setSexe(int Sexe)
{
	m_Sexe = Sexe;
} // setSexe()

int PLAYER::getClass() const
{
	return m_Class;
} // getClass()

void PLAYER::setClass(int Class)
{
	m_Class = Class;
} // setClass

int PLAYER::getLevel() const
{
	return m_Level;
} // getLevel()

void PLAYER::setLevel(int Level)
{
	m_Level = Level;
} // setLevel()

int PLAYER::getXp() const
{
	return m_Xp;
} // getLevel()

void PLAYER::setXp(int Xp)
{
	int CurrXp = Xp + getXp();
	if (CurrXp >= 100)
	{
		m_Xp = CurrXp - 100;
		this->setLevel(this->getLevel() + 1);
		*this = rpg::Option::UpCaract(*this);
	}
	else
		m_Xp = CurrXp;

	rpg::Option::Save(*this);
} // setLevel()

int PLAYER::getStr() const
{
	return m_Str;
} // getStr()

void PLAYER::setStr(int Str)
{
	m_Str = Str;
} // setStr()

int PLAYER::getDext() const
{
	return m_Dext;
} // getDext()

void PLAYER::setDext(int Dext)
{
	m_Dext = Dext;
} // setDext()

int PLAYER::getInt() const
{
	return m_Int;
} // getInt()

void PLAYER::setInt(int Int)
{
	m_Int = Int;
} // setInt()

int PLAYER::getHp() const
{
	return m_Hp;
} // getHp()

void PLAYER::setHp(int Hp)
{
	m_Hp = Hp;
} // setHp()

int PLAYER::getMp() const
{
	return m_Mp;
} // getMp()

void PLAYER::setMp(int Mp)
{
	m_Mp = Mp;
} // setMp()

int PLAYER::getWeapon() const
{
	return m_Weapon;
} // getWeapon()

void PLAYER::setWeapon(int Weapon)
{
	m_Weapon = Weapon;
} // setWeapon()

int PLAYER::getArmor() const
{
	return m_Armor;
} // getArmor()

void PLAYER::setArmor(int Armor)
{
	m_Armor = Armor;
} // setArmor()

int PLAYER::Defend()
{
	return getArmor();
}

int PLAYER::Attack(bool Crit)
{
	int Switch = getClass();
	switch(Switch)
	{
		case 0:
		  return (Crit) ? ((getStr()*getWeapon() - (getStr()+getWeapon())) >> 1) : getStr()+getWeapon();

		case 1:
		  return (Crit) ? ((getInt()*getWeapon() - (getInt()+getWeapon())) >> 1) : getInt()+getWeapon();

		case 2:
		  return (Crit) ? ((getDext()*getWeapon() - (getDext()+getWeapon())) >> 1) : getDext()+getWeapon();

		default:
		  return getWeapon();
	}
}

#undef PLAYER
